﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace BanHangCshap.DanhMuc.gkhtdl63.Khachhang2
{
    public partial class frmKhachhang2 : Form
    {
        public frmKhachhang2()
        {
            InitializeComponent();
        }

        Class.gkhtdl63.BLL.Khachhang2BLL xgKhachhangBLL = new BanHangCshap.Class.gkhtdl63.BLL.Khachhang2BLL();

        private void LoadKhach()
        {
            gcKhachhang2.DataSource = xgKhachhangBLL.Khachhang2_Laydanhsach(1);
        }

        private void frmKhachhang2_Load(object sender, EventArgs e)
        {
            LoadKhach();
        }

        private void btnThem_Click(object sender, EventArgs e)
        {
            DanhMuc.gkhtdl63.Khachhang2.frmKhachhang2Chitiet frm = new frmKhachhang2Chitiet(true, null);
            frm.Tailai += new MyEvent_LoadData(frm_Tailai);
            frm.ShowDialog();
        }

        void frm_Tailai(object sender, ELoadData e)
        {
            LoadKhach();
        }

        private void btnSua_Click(object sender, EventArgs e)
        {
            DanhMuc.gkhtdl63.Khachhang2.frmKhachhang2Chitiet frm = new frmKhachhang2Chitiet(false, gvKhachhang2.GetFocusedDataRow());
            frm.Tailai += new MyEvent_LoadData(frm_Tailai);
            frm.ShowDialog();
        }

        private void gvKhachhang2_DoubleClick(object sender, EventArgs e)
        {
            DanhMuc.gkhtdl63.Khachhang2.frmKhachhang2Chitiet frm = new frmKhachhang2Chitiet(false, gvKhachhang2.GetFocusedDataRow());
            frm.Tailai += new MyEvent_LoadData(frm_Tailai);
            frm.ShowDialog();
        }

        private void btnDong_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnTailai_Click(object sender, EventArgs e)
        {
            LoadKhach();
        }
    }
}
